/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package estates;

import estates.model.*;
import com.sun.webui.jsf.component.Label;
import com.sun.webui.jsf.component.StaticText;

import com.sun.data.provider.impl.ObjectListDataProvider;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Table;
import com.sun.webui.jsf.model.DefaultTableDataProvider;
import estates.model.Estate;
import estates.util.TransferUser;
import javax.faces.FacesException;
import java.util.*;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @version userinfo.java
 * @version Created on 2011-05-25, 19:43:46
 * @author Karol
 */

public class userinfo extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
    }
    private DefaultTableDataProvider defaultTableDataProvider = new DefaultTableDataProvider();

    public DefaultTableDataProvider getDefaultTableDataProvider() {
        return defaultTableDataProvider;
    }

    public void setDefaultTableDataProvider(DefaultTableDataProvider dtdp) {
        this.defaultTableDataProvider = dtdp;
    }
    private ObjectListDataProvider objectListDataProvider1 = new ObjectListDataProvider(this.getApplicationBean1().getOfertyUseraStringList(this.getRequestBean1().getUzytkownik()));

    public ObjectListDataProvider getObjectListDataProvider1() {
        return objectListDataProvider1;
    }

    public void setObjectListDataProvider1(ObjectListDataProvider oldp) {
        this.objectListDataProvider1 = oldp;
    }
    private ObjectListDataProvider objectListDataProvider2 = new ObjectListDataProvider(this.getApplicationBean1().getUserCommentsStringList(this.getRequestBean1().getUzytkownik()));

    public ObjectListDataProvider getObjectListDataProvider2() {
        return objectListDataProvider2;
    }

    public void setObjectListDataProvider2(ObjectListDataProvider oldp) {
        this.objectListDataProvider2 = oldp;
    }

    private ObjectListDataProvider objectListDataProvider3 = new ObjectListDataProvider(this.getApplicationBean1().getObserwowaneUseraStringList(this.getRequestBean1().getUzytkownik()));

    public ObjectListDataProvider getObjectListDataProvider3() {
        return objectListDataProvider3;
    }

    public void setObjectListDataProvider3(ObjectListDataProvider objectListDataProvider3) {
        this.objectListDataProvider3 = objectListDataProvider3;
    }


    
    private Table table1 = new Table();

    public Table getTable1() {
        return table1;
    }

    public void setTable1(Table t) {
        this.table1 = t;
    }
    private Table table2 = new Table();

    public Table getTable2() {
        return table2;
    }

    public void setTable2(Table t) {
        this.table2 = t;
    }

    TransferUser tu = new TransferUser(this.getApplicationBean1().getFasada().Szukaj_user(this.getRequestBean1().getUzytkownik()).toString());
    private StaticText us_typ = new StaticText();

    public StaticText getUs_typ() {
        return us_typ;
    }

    public void setUs_typ(StaticText st) {
        this.us_typ = st;
    }

    public TransferUser getTu() {
        return tu;
    }

    public void setTu(TransferUser tu) {
        this.tu = tu;
    }
    private StaticText us_login = new StaticText();

    public StaticText getUs_login() {
        return us_login;
    }

    public void setUs_login(StaticText st) {
        this.us_login = st;
    }
    private StaticText us_nazwisko = new StaticText();

    public StaticText getUs_nazwisko() {
        return us_nazwisko;
    }

    public void setUs_nazwisko(StaticText st) {
        this.us_nazwisko = st;
    }
    private StaticText us_pesel = new StaticText();

    public StaticText getUs_pesel() {
        return us_pesel;
    }

    public void setUs_pesel(StaticText st) {
        this.us_pesel = st;
    }
    private StaticText us_miasto = new StaticText();

    public StaticText getUs_miasto() {
        return us_miasto;
    }

    public void setUs_miasto(StaticText st) {
        this.us_miasto = st;
    }
    private StaticText us_ulica = new StaticText();

    public StaticText getUs_ulica() {
        return us_ulica;
    }

    public void setUs_ulica(StaticText st) {
        this.us_ulica = st;
    }
    private StaticText us_numerdomu = new StaticText();

    public StaticText getUs_numerdomu() {
        return us_numerdomu;
    }

    public void setUs_numerdomu(StaticText st) {
        this.us_numerdomu = st;
    }
    private StaticText us_kodpocztowy = new StaticText();

    public StaticText getUs_kodpocztowy() {
        return us_kodpocztowy;
    }

    public void setUs_kodpocztowy(StaticText st) {
        this.us_kodpocztowy = st;
    }
    private StaticText us_regon = new StaticText();

    public StaticText getUs_regon() {
        return us_regon;
    }

    public void setUs_regon(StaticText st) {
        this.us_regon = st;
    }
    private StaticText us_nip = new StaticText();

    public StaticText getUs_nip() {
        return us_nip;
    }

    public void setUs_nip(StaticText st) {
        this.us_nip = st;
    }
    private StaticText us_mail = new StaticText();

    public StaticText getUs_mail() {
        return us_mail;
    }

    public void setUs_mail(StaticText st) {
        this.us_mail = st;
    }
    private StaticText us_telefon = new StaticText();

    public StaticText getUs_telefon() {
        return us_telefon;
    }

    public void setUs_telefon(StaticText st) {
        this.us_telefon = st;
    }
    private StaticText us_infdodatkowe = new StaticText();

    public StaticText getUs_infdodatkowe() {
        return us_infdodatkowe;
    }

    public void setUs_infdodatkowe(StaticText st) {
        this.us_infdodatkowe = st;
    }

    boolean showRegon = false;
    boolean showPesel = true;

    public boolean isShowPesel() {
        return showPesel;
    }

    public void setShowPesel(boolean showPesel) {
        this.showPesel = showPesel;
    }

    public boolean isShowRegon() {
        return showRegon;
    }

    public void setShowRegon(boolean showRegon) {
        this.showRegon = showRegon;
    }
    private Label label8 = new Label();

    public Label getLabel8() {
        return label8;
    }

    public void setLabel8(Label l) {
        this.label8 = l;
    }
    private Label label7 = new Label();

    public Label getLabel7() {
        return label7;
    }

    public void setLabel7(Label l) {
        this.label7 = l;
    }
    private Table table3 = new Table();

    public Table getTable3() {
        return table3;
    }

    public void setTable3(Table t) {
        this.table3 = t;
    }

    

    // </editor-fold>

    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public userinfo() {
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     * 
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here

        String us = this.getRequestBean1().getUzytkownik();
        if(us != null && us.length()>0){

            User uu = this.getApplicationBean1().getFasada().Szukaj_user(us);

            //List<Estate> estates = uu.getEstates();
            /*for (Estate e : estates)
                System.out.print(e);*/
            //System.out.print("--------------");
            //List<Comment> comments = uu.getComments();
            //for (Comment c : comments)

            if(uu != null){
                tu = new TransferUser(uu.toString());
            }

        }

        showPesel = !tu.getUserType().equals("firma");
        showRegon = tu.getUserType().equals("firma");
        
        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("userinfo Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
        }
        
        // </editor-fold>
        // Perform application initialization that must complete
        // *after* managed components are initialized
        // TODO - add your own initialization code here
    }

    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit.  Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    @Override
    public void preprocess() {
    }

    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).  Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    @Override
    public void prerender() {
    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    @Override
    public void destroy() {
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }
    
}

